package com.vdf.sisconsolid.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.vdf.sisconsolid.archive.CivilStatusManager;
import com.vdf.sisconsolid.archive.DaysManager;
import com.vdf.sisconsolid.persistencemodule.dao.AddressDao;
import com.vdf.sisconsolid.persistencemodule.dao.NetDao;
import com.vdf.sisconsolid.persistencemodule.dao.TracingTypeDao;
import com.vdf.sisconsolid.persistencemodule.dto.KeyValueBean;
import com.vdf.sisconsolid.persistencemodule.model.TracingType;

public class CacheSC {
	
	private static final Map<String, Object> cache = new HashMap<String, Object>();
	
	@SuppressWarnings("unchecked")
	public static Map<Byte, String> getCivilStatus() {
		if (cache.get("cs") == null) {
			cache.put("cs", CivilStatusManager.getCivilStatus());
		}
		return (Map<Byte, String>) cache.get("cs");
	}
	
	@SuppressWarnings("unchecked")
	public static List<TracingType> getTracingTypes() {
		if (cache.get("tt") == null) {
			cache.put("tt", new TracingTypeDao().getTracingTypeList());
		}
		return (List<TracingType>) cache.get("tt");
	}
	
	@SuppressWarnings("unchecked")
	public static List<KeyValueBean> getProvinceList() {
		if (cache.get("provinceList") == null){			
			cache.put("provinceList", new AddressDao().getProvinceList());
		}
		return (List<KeyValueBean>) cache.get("provinceList");
	}
	
	@SuppressWarnings("unchecked")
	public static List<KeyValueBean> getCityList(Integer provinceId, Map<String, Object> parameters){ 
		if (cache.get(provinceId + "_cityList") == null) {
			cache.put(provinceId + "_cityList", new AddressDao().getCityList(parameters));
		}
		return (List<KeyValueBean>) cache.get(provinceId + "_cityList");
	}

	@SuppressWarnings("unchecked")
	public static List<KeyValueBean> getNetList() {
		if (cache.get("netList") == null) {
			cache.put("netList", new NetDao().getNetList());
		}
		return (List<KeyValueBean>) cache.get("netList");
	}
	
	@SuppressWarnings("unchecked")
	public static Map<Byte, String> getDays() {
		if (cache.get("days") == null) {
			cache.put("days", DaysManager.getDays());
		}
		return (Map<Byte, String>) cache.get("days");
	}

}
